/*
 * CBladeFlurry.java
 * 
 * Copyright (c) 2009 Giles Millward (Manigra). All rights reserved.
 * 
 * This file is part of Expression program is undefined on line 8, column 40 in Templates/Licenses/license-gplv3.txt..
 * 
 * Expression program is undefined on line 10, column 19 in Templates/Licenses/license-gplv3.txt. is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Expression program is undefined on line 15, column 19 in Templates/Licenses/license-gplv3.txt. is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Expression program is undefined on line 21, column 30 in Templates/Licenses/license-gplv3.txt..  If not, see <http://www.gnu.org/licenses/>.
 */

package dpssystem;

/**
 *
 * @author Mani
 */
public class CBladeFlurry extends CAbility {

    double m_endOfBladeFlurry = -0.1;
    double m_nextAvailable = 0.0; // Time when next available
    double m_cooldownTime = 120.0; // 2 minute CD
    double m_bladeFlurryDuration = 15.0; // 15 second duration
    boolean m_bladeFlurryEnabled = false;

    CBladeFlurry(CSim p_sim)
    {
        super(p_sim, false);
        m_energyRequired = 25;
        m_bladeFlurryEnabled = (m_sim.m_dpsInterface.m_talents.getBladeFlurry() != 0) ? true:false;
        if (m_sim.m_dpsInterface.m_glyphs.m_bladeFlurry)
        {
            m_energyRequired = 0;
        }
    }

    public boolean canExecute()
    {
        // Blade flurry not available
        if (!m_bladeFlurryEnabled)
        {
            return false;
        }

        // Still on cooldown
        if (m_sim.m_currentRunTime <= m_nextAvailable)
        {
            return false;
        }

        if (m_sim.m_player.m_energyRegen.m_currentEnergy < m_energyRequired)
        {
            // Not enough energy
            return false;
        }

        if (m_sim.m_currentRunTime < m_sim.m_gcd.m_endOfGCD)
        {
            // Still on GCD
            return false;
        }

        return true;
    }

    public void execute()
    {
        m_nextAvailable = m_sim.m_currentRunTime + m_cooldownTime;
        m_endOfBladeFlurry = m_sim.m_currentRunTime + m_bladeFlurryDuration;
        m_sim.m_player.m_energyRegen.useAbilityEnergy(m_energyRequired);
    }

    public double getHaste()
    {
        if (m_sim.m_currentRunTime <= this.m_endOfBladeFlurry)
        {
            // Haste boosted by 20%
            return 0.20;
        }

        return 0.0;
    }
}
